let fs = require('fs');
let path = require('path');
let express = require('express');
let router = express.Router();

//根据文件名，动态加载各个子模块
let file = fs.readdirSync(__dirname);
file.forEach(function(module) {
  let moduleIndex = path.join(__dirname, module, 'index.js');
  if (fs.existsSync(moduleIndex)) {
    router.use('/', require('./' + module));
  }
});

module.exports = router;
